package com.example.chapter6.util;

import java.sql.Connection;
import java.sql.DriverManager;

public class DBConnection {
    private String FileName;
    private int DBType;
    private Connection conn;
    private String MySQLDriver;
    private String MySQLURL;

    public DBConnection() {
        conn = null;
    }
    public Connection getConn() {
        DBType = 1;
        switch (DBType) {
            case 1:
                return (getConnToMySQL());
            default:
                return null;
        }
    }
    public Connection getConnToMySQL(){
        try {
            MySQLDriver ="com.mysql.cj.jdbc.Driver";
            MySQLURL ="jdbc:mysql://localhost;3306/三克油"+"user =root&password=mysql123456& "+"useUnicode=true&characterEncoding=utf8";
            Class.forName(MySQLDriver);
            conn = DriverManager.getConnection(MySQLURL);

        }catch (Exception e){}
        return conn;
    }
}
